<!DOCTYPE html>
<html>
<head>
    <title>后台管理</title>
    <style type="text/css" rel="stylesheet">
        html,body{width:100%;height:100%;margin:0;padding:0;font-family:"lucida grande", "lucida sans unicode", lucida, helvetica, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;}
        .header{height:40px;width:100%;background-color:#242424;position:fixed;}
        .header_title{line-height:40px;margin-left:60px;color:#fff;font-size:15px;}
        .header_user{font-size:12px;margin-left:20px;color:#ccc;}
        .panel{width:380px;height:500px;margin-left:auto;margin-right:auto;padding-top:100px;font-size:14px;}
        a{text-decoration: none;color:#fff;}
        .login_input>span{display: inline-block;width:130px;}
        input{height:28px;line-height:28px;width:300px;border:1px solid #ddd; border-radius:4px;margin-left:5px;margin-bottom:10px;outline: none;padding-left:10px;}
    </style>
</head>
<body>
    <div class="header">
        <div class="header_title"><a href="/">后台管理系统</a></div>
    </div>
    <div class="panel">
        <div class="login_input">
            <span>用户名</span>
            <input id="uname" placeholder="请输入用户名"/>
        </div>
        <div class="login_input">
            <span>真实姓名</span>
            <input id="realName" placeholder="请输入真实姓名"/>
        </div>
        <div class="login_input">
            <span>性别</span>
            <input id="sex" placeholder="请输入性别"/>
        </div>
        <div id="btn" style="background-color:#3C74F2;width:306px;height:32px;line-height:32px;text-align: center;color:#fff;border-radius:4px;margin-top:30px;margin-left:60px;">
            注册
        </div>
    </div>
    <script type="text/javascript" src="/js/jquery-3.1.1.js"></script>
    <script type="text/javascript">
        $('#btn').on('click', function(){
            var realName = $('#realName').val();
            var uname = $('#uname').val();
            var sex=$('#sex').val();
            var obj = {
                uname: uname,
                sex: sex,
                realName:realName,
                type:'users'
            };
            $.ajax({
                type: 'POST',
                url: '/data/save',
                data: obj,
                success: function(data){
                    if(data.status){
                        window.location.href = '/index';
                    }else{
                        alert('注册失败');
                    }
                },
                error: function(){
                    alert('注册失败');
                },
                dataType: 'json'
            });
        });
    </script>
</body>
</html>
